package chapter03;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

public class Q1<E> {


    public static void main(String[] args) {
        Q1<String> q1 = new Q1<>();
        List<String> list = new ArrayList<>();
        list.add("a");
        list.add("b");
        list.add("c");
        list.add("d");

        List<Integer> list2 = new ArrayList<>();
        list2.add(1);
        list2.add(4);

        q1.printLots(list, list2);

    }

    public void printLots(List<E> L, List<Integer> P) {
        Iterator<E> iteratorL = L.iterator();
        Iterator<Integer> iteratorP = P.iterator();
        int start = 0;
        E item = null;
        int itemP;

        while (iteratorL.hasNext() && iteratorP.hasNext() ) {
            itemP = iteratorP.next();
            System.out.println("Looking for position " + itemP);
            while (iteratorL.hasNext() && start < itemP) {
                start ++;
                item = iteratorL.next();
            }
            System.out.println("-> " + item);
        }
    }

}
